import axios from "axios";

export default {
  namespaced: true,
  state: {
    Item: [],
  },
  mutations: {
    SET_Item(state, data) {
      state.Item = data;
    },
  },
  actions: {
    async GetItem({ commit }, id) {
      const res = await axios({
        url: `http://localhost:10000/ArticleTable/${id}`,
      });
      commit("SET_Item", res.data);
    },

    async updateArticle(context, { id, data }) {
      const res = await axios({
        method: "PUT",
        url: `http://localhost:10000/ArticleTable/${id}`,
        data,
      });
      console.log(res.data);
    },

    async delArticle(context, id) {
      const res = await axios({
        method: "DELETE",
        url: `http://localhost:10000/ArticleTable/${id}`,
      });
      console.log(res);
    },
  },
};
